//
//  TitleTableViewCell.m
//  薄荷家具
//
//  Created by dllo on 15/12/22.
//  Copyright © 2015年 蓝鸥科技. All rights reserved.
//

#import "TitleTableViewCell.h"
#import "Items.h"
#import "UIImageView+WebCache.h"
@implementation TitleTableViewCell

-(void)dealloc
{
    [_picture release];
    [_titleLabel release];
    [_item release];
    [_view release];
    [super dealloc];
}

-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        self.picture = [[UIImageView alloc]init];
        self.picture.backgroundColor = [UIColor yellowColor];
        self.picture.layer.cornerRadius = 10;
        self.picture.layer.masksToBounds = YES;
        
        [self.contentView addSubview:self.picture];
        [self.picture release];
        
        
        self.titleLabel = [[UILabel alloc] init];
        self.titleLabel.font = [UIFont systemFontOfSize:20 weight:3];
        self.titleLabel.textColor = [UIColor whiteColor];
//        self.titleLabel.backgroundColor = [UIColor grayColor];
        [self.contentView addSubview:self.titleLabel];
        [self.titleLabel release];
        
        self.view = [[UIView alloc]init];
        self.view.backgroundColor = [UIColor whiteColor];
        [self.contentView addSubview:self.view];
        [_view release];
       
    }
    return self;
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    self.picture.frame = CGRectMake(5, 0, kWidth - 10 , 140 * sHeight);
    self.titleLabel.frame = CGRectMake(5, 100 * sHeight, kWidth, 50 * sHeight);
    self.view.frame = CGRectMake(5,140 * sHeight , kWidth, 10 * sHeight);
}

-(void)setItem:(Items *)item
{
    if (_item != item) {
        [_item release];
        _item = [item retain];
    }
    [self.picture sd_setImageWithURL:[NSURL URLWithString:item.cover_image_url]];
    
    self.titleLabel.text = item.title;
    
    
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
